using System.IO;
using Core;
using EnvDTE;

namespace RevisionItNow.Features
{
	public class AutoRenameFeature : Feature
	{
		private readonly ProjectItemsEvents _events;

        public AutoRenameFeature(Ide ide, OutputPane outputPane)
			: base("Auto Rename", ide, outputPane)
		{
			_events = ide.ProjectItemsEvents;

			if (_events != null)
				_events.ItemRenamed += OnItemRenamed;
		}

		public void OnItemRenamed(ProjectItem projectItem, string oldName)
		{
            Mercurial.Rename(Path.GetDirectoryName(projectItem.FileNames[0] + "\\" + oldName), projectItem.FileNames[0]);
		}
	}
}